package com.lanhe.app.controller.member;


import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.framework.web.service.AppLoginService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 *
 *
 * @author zhanggl
 * @date 2023/12/11
 */
@RestController
@RequestMapping("/api/login/")
public class ApiLoginController extends BaseController {


    @Autowired
    private AppLoginService appLoginService;

    /**
     * @Description 手机app 微信授权登录
     * @MethodName login
     * @Param [loginDTO]
     * @ReturnType com.lanhe.common.core.domain.AjaxResult
     * @Date  2023/12/1 11:18
     * @Author zxx
     * @Since 1.0
     */
    @GetMapping("/wechatLogin")
    public AjaxResult wechatLogin(@RequestParam(value = "code", required = false) String code)  throws Exception{
        if(StringUtils.isBlank(code)){
            return error("授权失败，code不能为空");
        }
        Map<String, Object> resMap = appLoginService.wechatLogin(code);

        System.out.println(resMap);
        return success(resMap);
    }
}
